const TIME_INFO = "time_info"
const WINDOW_SIZE_KEY = "window_size"
const ALARMS_INFO_KEY = "alarms_info"
const THEME_COlOR = "theme_color"
const RESETZZ_STATUS = "reset_status"

// 存储设置的倒计时信息
export const saveTimeInfo = (form) => {
    localStorage.setItem(TIME_INFO, JSON.stringify(form))
}

// 读取倒计时信息
export const readTimeInfo = () => {
    return JSON.parse(localStorage.getItem(TIME_INFO)) == null ? { minute: 0, second: 0 } : JSON.parse(localStorage.getItem(TIME_INFO))
}

// 清除倒计时信息
export const clearTimeInfo = () => {
    localStorage.removeItem(TIME_INFO)
}

// 保存窗口大小信息
export const saveWindowSizeInfo = (size) => {
    localStorage.setItem(WINDOW_SIZE_KEY, JSON.stringify(size))
} 

// 获取窗口大小信息
export const readWindowSizeInfo = () => {
    return JSON.parse(localStorage.getItem(WINDOW_SIZE_KEY)) == null ? 400 : JSON.parse(localStorage.getItem(WINDOW_SIZE_KEY)) 
} 

// 清除窗口大小信息
export const clearWindowsSizeInfo = () => {
    localStorage.removeItem(WINDOW_SIZE_KEY)
}

// 存储闹铃信息
export const saveAlramsInfo = (alarmsInfo) => {
    localStorage.setItem(ALARMS_INFO_KEY, JSON.stringify(alarmsInfo))
}

// 获取闹铃信息
export const readAlramsInfo = () => {
    return JSON.parse(localStorage.getItem(ALARMS_INFO_KEY)) == null ? [] : JSON.parse(localStorage.getItem(ALARMS_INFO_KEY)) 
}

// 清除闹铃信息
export const clearAlarmsInfo = () => {
    localStorage.removeItem(ALARMS_INFO_KEY)
}

// 保存主题色
export const saveThemeColor = (themeColor) => {
    localStorage.setItem(THEME_COlOR, JSON.stringify(themeColor))
}

// 获取主题色
export const readThemeColor = () => {
    return JSON.parse(localStorage.getItem(THEME_COlOR)) == null ? 'white' : JSON.parse(localStorage.getItem(THEME_COlOR)) 
}

// 清除主题色
export const clearThemeColor = () => {
    localStorage.removeItem(THEME_COlOR)
}

// 保存倒计时结束是否自动重置的状态
export const saveResetStatus = (isAutoReset) => {
    localStorage.setItem(RESETZZ_STATUS, JSON.stringify(isAutoReset))
}

// 获取倒计时结束是否自动重置的状态
export const readResetStatus = () => {
    return JSON.parse(localStorage.getItem(RESETZZ_STATUS)) == null ? true : JSON.parse(localStorage.getItem(RESETZZ_STATUS)) 
}